<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;

class Workflow extends Model
{
    //
	protected $table='workflow';
	protected $fillable=['name','level','type','style','one','two','three','four','status','company_id','create_name','create_uid'];
	protected $hidden=[];
	public function lists($where){
		return $this->where(function ($query) use($where){
			$query->where(['company_id'=>1]);
			if($where['name'] !=null){
				$query->where('name','like','%'.$where['name'].'%');
			}
			if($where['status'] !=null){
				$query->where('status','=',$where['status']);
			}
		})->with('userInfo')->get();
	}
	public function userInfo(){
		return $this->belongsTo('App\Model\Users','create_uid');
	}

	public function shengqin_jl($data){
		return $this->where(['id'=>$data['workflow_id']])->where(function ($query) use($data){
			if($data['step']==1){
				$query->whereNotNull('two');
			}
			if($data['step']==2){
				$query->whereNotNull('three');
			}
			if($data['step']==3){
				$query->whereNotNull('four');
			}

		})->first();
	}


//	查询业务组详情
	public function desc($id){
			$data=$this->where(['id'=>$id])->with('workflow_group')->first();
			return $data;
	}



}
